package com.hoas.quickstart.threads.chapter02.chapter02_2_9_01;

public class Service {

    synchronized public static void printA() {
        try {

            System.out.println("线程名为：" + Thread.currentThread().getName()
                + "在 " + System.currentTimeMillis() + " 进入printA");

            Thread.sleep(3000);

            System.out.println("线程名为：" + Thread.currentThread().getName()
                    + "在 " + System.currentTimeMillis() + " 离开printA");

        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }

    synchronized public static void printB() {

            System.out.println("线程名为：" + Thread.currentThread().getName()
                    + "在 " + System.currentTimeMillis() + " 进入printB");


            System.out.println("线程名为：" + Thread.currentThread().getName()
                    + "在 " + System.currentTimeMillis() + " 离开printB");

    }

    synchronized public void printC() {

        System.out.println("线程名为：" + Thread.currentThread().getName()
                + "在 " + System.currentTimeMillis() + " 进入printC");


        System.out.println("线程名为：" + Thread.currentThread().getName()
                + "在 " + System.currentTimeMillis() + " 离开printC");

    }

}
